﻿@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center" id="app">

    <div>
        <span>添加指令到RabbitMQ</span>
        <input type="text" name="orderID" value="" v-model="orderID" />
        <input type="button" name="publish" value="发布" v-on:click="push" />
        <input type="button" name="publish" value="更新" v-on:click="updateOrder" />
        <input type="button" name="publish" value="删除" v-on:click="deleteOrder" />
    </div>
    <div>
        <span>查询通过MongoDB</span>
        <input type="text" name="wd" value="" style="width:500px;" v-model="wd" />
        页数：<input type="text" name="pageindex" value="" style="width:40px;" v-model="pageindex" />
        显示条数:<input type="text" name="pagesize" value="" style="width:40px;" v-model="pagesize" />
        <input type="button" name="submit" value="查询" v-on:click="pull" />
        <div id="datalist"></div>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            orderID: "",
            wd: "",
            pageindex:"",
            pagesize:""
        },
        created: function () {

        },
        methods: {
            push: function () {
                axios.get("/HomeToEs/Push").then(function (response) {
                    if (response.data.status == "1001") {
                        alert("插入成功")
                    }
                    console.log(response.data)
                })
            },
            updateOrder: function () {
                axios.get("/HomeToEs/Update", {
                    params: {
                        orderID: this.orderID,
                    }
                }).then(function (response) {
                    if (response.data.status == "1001") {
                        alert("更新成功")
                    }
                    console.log(response.data)
                })
            },
            deleteOrder: function () {
                axios.get("/HomeToEs/Delete", {
                    params: {
                        orderID: this.orderID,
                        name: 'Henry',
                    }
                }).then(function (response) {
                    if (response.data.status == "1001") {
                        alert("删除成功")
                    }
                    console.log(response.data)
                })
            },
            pull: function () {
                console.log(this.wd);
                axios.get("/HomeToEs/Pull", {
                    params: {
                        wd: this.wd,
                        from: this.pageindex,
                        size: this.pagesize
                    }
                }).then(function (response) {
                    console.log(response.data)
                })
            }
        }
    });
</script>
